package com.merry.spring5.resource;

import java.io.IOException;
import java.io.InputStream;

import org.springframework.core.io.FileSystemResource;

/**
 * @author ybzou
 * 访问系统文件资源
 */
public class FileSystemResourceDemo {

    public static void main(String[] args) throws Exception {
        loadFileSysResource("D:\\spring5_log_app.log");
    }

    public static void loadFileSysResource(String path) throws Exception {
        FileSystemResource fileSystemResource = new FileSystemResource(path);

        System.out.println(fileSystemResource.getFilename());
        System.out.println(fileSystemResource.getDescription());
        InputStream inputStream = fileSystemResource.getInputStream();
        byte[] bytes=new byte[1024];
        while (inputStream.read(bytes) != -1){
            System.out.println(new String(bytes));
        }
    }
}
